<meta title="添加免单活动" width="800px" args="freeChargeActivity"/>
<div class="p">
    <form s="valid,form,nda,datac"
          id="form" class="form-horizontal"
          method="post"
          s-data="freeChargeActivity"
          action="api/freeChargeActivity">
        <table class="table table-striped table-bordered">
            <tr>
                <td style="width: 100px" class="text-right">名称</td>
                <td>
                    <input type="text" autocomplete="off" class="form-control" s-valid-error="require()" name="name" placeholder="输入名称" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">按钮文字</td>
                <td>
                    <input type="text" autocomplete="off" class="form-control" s-valid-error="require()" name="btnTitle" placeholder="按钮文字" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px;">打标Icon</td>
                <td s="tpl" id="icon" s-valie-role="item" s-click="selectIcon()" s-valid-role="item">
                    <img src="{%=this.markIconUrl || 'images/upload-bg.jpg'%}" class="adv-img" style="max-width: 100px; max-height: 50px;" />
                    <input autocomplete="off" type="hidden" name="markIcon" s-valid-error="require()" value="{%=this.markIcon%}" />
                    <input autocomplete="off" type="hidden" name="markIconUrl" s-valid-error="require()" value="{%=this.markIconUrl%}" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">开始时间</td>
                <td>
                    <input type="text" autocomplete="off" class="form-control" s-valid-error="require()" name="startTime" s="datetimepicker" placeholder="开始时间" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">结束时间</td>
                <td>
                    <input type="text" autocomplete="off" class="form-control" s-valid-error="require()" name="endTime" s="datetimepicker" placeholder="结束时间" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">频次类型</td>
                <td>
                    <select class="form-control input-sm" s="select"
                            name="freq"
                            s-build="S.get('/api/enum/valuesMap/core.enums.ActivityFreq')">
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">频次次数</td>
                <td>
                    <input type="text" autocomplete="off" class="form-control" s-valid-error="require()" name="maxUserDrawNum" placeholder="频次次数" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">人群</td>
                <td>
                    <select class="form-control input-sm" s="select"
                            name="crowdId"
                            s-build="S.get('/api/crowd/list/VALID')">
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">物料</td>
                <td>
                    <select class="form-control input-sm" s="select"
                            name="materialId"
                            s-build="S.get('/api/material/list/VALID')">
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">帮助页面</td>
                <td>
                    <input type="text" autocomplete="off" class="form-control" s-valid-error="require()" name="helpUrl" placeholder="帮助页面" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">确认描述</td>
                <td>
                    <textarea class="form-control" s-valid-error="require()" name="confirmDescription" placeholder="确认描述"></textarea>
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">描述</td>
                <td>
                    <textarea class="form-control" name="description" placeholder="输入描述"></textarea>
                </td>
            </tr>
            <tr>
                <td style="width: 100px" class="text-right">状态</td>
                <td>
                    <select class="form-control input-sm" s="select"
                            name="status"
                            s-build="S.get('/api/enum/valuesMap/core.enums.RedPacketStatus?igNames=DELETED')">
                    </select>
                </td>
            </tr>
        </table>
        <input autocomplete="off" type="hidden" name="typeConfig" id="config" />
    </form>
</div>
<style>
</style>
<script type="text/javascript">
    if(freeChargeActivity) {
        $form.node.attr("method", "put")
        $form.node.attr("action", "/api/freeChargeActivity/" + freeChargeActivity.id);
    }
    S.meta.btns = [
        {
            name: "保存",
            style: "btn btn-primary",
            click: function() {
                $form.validate().done(function(){
                    $form.submit().done(function() {
                        S.close(true)
                    })
                })
            }
        },
        {
            name: "关闭",
            style: "btn btn-default",
            click: function() {
                S.close();
            }
        }
    ]

    function selectIcon() {
        S.popupOpen("/oss/objects-selector.html", {prefix: 'adv'}).done(function(datas) {
            if(datas) {
                var icon = datas[0];
                $icon.data({
                    markIcon: icon.key,
                    markIconUrl: icon.url,
                })
            }
        })
    }

</script>